// core_logic.c
#include "core_logic.h"
#include <string.h>
#include <stdlib.h>

static StateUpdateCallback state_callback = NULL;
static char app_state[256] = {0};

void core_init(StateUpdateCallback callback) {
    state_callback = callback;
    strcpy(app_state, "initial_state");
    
    // 通知UI初始状态
    if (state_callback) {
        state_callback("app_state", app_state);
    }
}

void core_handle_event(const char* event_type, const char* event_data) {
    if (strcmp(event_type, "button_click") == 0) {
        strcpy(app_state, "button_clicked");
        
        // 通知UI状态变化
        if (state_callback) {
            state_callback("app_state", app_state);
        }
    }
    // 处理其他事件...
}

const char* core_get_state(const char* key) {
    if (strcmp(key, "app_state") == 0) {
        return app_state;
    }
    return NULL;
}